<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class CouponResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'coupon_id' => $this->id,
            'title' => $this->title,
            'type' => $this->type,   // 优惠券类型 1满减券 2折扣券
            'type_name' => $this->type_name,   // 优惠券类型 1满减券 2折扣券
            'price' => $this->price,  //减免金额 当type为1
            'full_reduction_amount' => $this->full_reduction_amount,  //门槛金额
            'discount_rate' => floor($this->discount_rate / 10),  //折扣率 百分比
            'desc' => $this->description,
            'time' => $this->time,
            'send_count' => $this->send_count,
            'is_receive' => $this->is_receive,
            'product_name' => $this->product_name,
        ];
    }
}
